**Project: Strategic Discrimination**
**by Regina Bateson**
**Last modified: 21 June 2020**

//This do-file provides the output for the Study 1 results//

//First, the do-file cleans and re-organizes the dataset.//
//Then, the "Analysis 1" section provides the main results in the manuscript.//
//Last, the "Analysis 2" section provides supplemental analysis cited in the manuscript and the appendix.//

**GET THE DATASET**

//Download and save the file Study1.dta //
//It is part of this replication package // 

use "/Users/gina/Dropbox (Personal)/Strategic Discrimination resubmit/Perspectives Final Submission/Data and Replication Files/Study1.dta"

//Of course your version of the dataset is saved differently. Go open it.//

**CLEAN THE DATA AND SET UP VARIABLES**

gen female=0
replace female=1 if gender=="Female"
rename female femaleresp

gen male=0
replace male=1 if gender=="Male"
rename male maleresp

encode birthyear, gen(birthyear2)
drop birthyear
rename birthyear2 birthyear

gen millenial=0
replace millenial=1 if birthyear>56
**For some reason 1984 is coded as 56** 

gen boomerandabove=0
replace boomerandabove=1 if birthyear<36
**1965 is coded as 36**

gen white=0
replace white=1 if race=="Caucasian/White (non-Hispanic)"
rename white whiteresp

gen black=0
replace black=1 if race=="Black or African-American (non-Hispanic)"
rename black blackresp

gen hispanic=0
replace hispanic=1 if race=="Latino or Hispanic"
rename hispanic hispanicresp

gen api=0
replace api=1 if race=="Asian/Pacific Islander"
rename api apiresp
**I renamed all the variables above to clarify that they are coding the race of the subject (not the candidate profiles)**

rename income income2
gen income=.
replace income=1 if income2=="Less than $10,000"
replace income=2 if income2=="$10,000-$19,999"
replace income=3 if income2=="$20,000-$29,999"
replace income=4 if income2=="$30,000-$39,999"
replace income=5 if income2=="$40,000-$49,999"
replace income=6 if income2=="$50,000-$74,999"
replace income=7 if income2=="$75,000-$99,999"
replace income=8 if income2=="$100,000-$149,999"
replace income=9 if income2=="$150,000 or more"
drop income2

rename education education2
gen education=.
replace education=1 if education2=="Did not graduate from high school"
replace education=2 if education2=="High school graduate"
replace education=3 if education2=="Some college, but no degree"
replace education=4 if education2=="2-year college degree"
replace education=5 if education2=="4-year college degree"
replace education=6 if education2=="Postgraduate degree (MA, MBA, JD, PhD, etc.)"

gen married=0
replace married=1 if maritalstatus=="Married"

gen age=90-birthyear

rename evangelical evangelical2
gen evangelical=0
replace evangelical=1 if evangelical2=="Yes"
drop evangelical2

gen conservative=0
replace conservative=1 if ideology=="Conservative"

gen liberal=0 
replace liberal=1 if ideology=="Liberal"

gen noideology=0
replace noideology=1 if ideology=="Haven't thought much about it"
**Note, I think this is another measure of people who are politically disengaged or confused.**

gen democrat=0
replace democrat=1 if partyid=="Democrat"

gen independent=0
replace independent=1 if partyid=="Independent"

gen republican=0
replace republican=1 if partyid=="Republican"

gen noreligion=0
replace noreligion=1 if religion=="None"

gen catholic=0
replace catholic=1 if religion=="Roman Catholic"

gen protestant=0
replace protestant=1 if religion=="Protestant"

gen west=0
replace west=1 if state=="Washington"
replace west=1 if state=="Alaska"
replace west=1 if state=="Hawaii"
replace west=1 if state=="California"
replace west=1 if state=="Arizona"
replace west=1 if state=="Oregon"
replace west=1 if state=="Nevada"
replace west=1 if state=="New Mexico"
gen mountain=0
replace mountain=1 if state=="Idaho"
replace mountain=1 if state=="Montana"
replace mountain=1 if state=="Colorado"
replace mountain=1 if state=="Utah"
replace mountain=1 if state=="Wyoming"
gen south=0
replace south=1 if state=="Texas"
replace south=1 if state=="Alabama"
replace south=1 if state=="Louisiana"
replace south=1 if state=="Arkansas"
replace south=1 if state=="Mississippi"
replace south=1 if state=="Tennessee"
replace south=1 if state=="Kentucky"
replace south=1 if state=="West Virginia"
replace south=1 if state=="Virginia"
replace south=1 if state=="South Carolina"
replace south=1 if state=="North Carolina"
replace south=1 if state=="Florida"
replace south=1 if state=="Georgia"
replace south=1 if state=="Maryland"
gen east=0
replace east=1 if state=="Delaware"
replace east=1 if state=="Pennsylvania"
replace east=1 if state=="Rhode Island"
replace east=1 if state=="New Jersey"
replace east=1 if state=="New York"
replace east=1 if state=="Connecticut"
replace east=1 if state=="Massachusetts"
replace east=1 if state=="Maine"
replace east=1 if state=="New Hampshire"
replace east=1 if state=="Vermont"
gen dc=0
replace dc=1 if state=="District of Columbia"
gen midwest=0
replace midwest=1 if state=="Ohio"
replace midwest=1 if state=="Michigan"
replace midwest=1 if state=="Indiana"
replace midwest=1 if state=="Illinois"
replace midwest=1 if state=="Iowa"
replace midwest=1 if state=="Minnesota"
replace midwest=1 if state=="Wisconsin"
replace midwest=1 if state=="North Dakota"
replace midwest=1 if state=="South Dakota"
replace midwest=1 if state=="Nebraska"
replace midwest=1 if state=="Kansas"
replace midwest=1 if state=="Oklahoma"
replace midwest=1 if state=="Missouri"


**Create a variable to indicate if the respondent lives in a state that has had a female governor since 1990 (that is, in the last 30 years).**

gen femalegov30=0
replace femalegov30=1 if state=="Kansas"
replace femalegov30=1 if state=="Oregon"
replace femalegov30=1 if state=="Texas"
replace femalegov30=1 if state=="New Jersey"
replace femalegov30=1 if state=="New Hampshire"
replace femalegov30=1 if state=="Arizona"
replace femalegov30=1 if state=="Ohio"
replace femalegov30=1 if state=="Montana"
replace femalegov30=1 if state=="Delaware"
replace femalegov30=1 if state=="Massachusetts"
replace femalegov30=1 if state=="South Dakota"
replace femalegov30=1 if state=="Hawaii"
replace femalegov30=1 if state=="Michigan"
replace femalegov30=1 if state=="Utah"
replace femalegov30=1 if state=="Louisiana"
replace femalegov30=1 if state=="Connecticut"
replace femalegov30=1 if state=="Washington"
replace femalegov30=1 if state=="Alaska"
replace femalegov30=1 if state=="North Carolina"
replace femalegov30=1 if state=="New Mexico"
replace femalegov30=1 if state=="Oklahoma"
replace femalegov30=1 if state=="Maine"
replace femalegov30=1 if state=="South Carolina"
replace femalegov30=1 if state=="Rhode Island"
replace femalegov30=1 if state=="Alabama"
replace femalegov30=1 if state=="Vermont"
replace femalegov30=1 if state=="Nebraska"
replace femalegov30=1 if state=="Iowa"

**Now create a variable to indicate if the respondent lives in a state that had a female governor at the time of the experiment.**

gen femalegovnow=0
replace femalegovnow=1 if state=="Rhode Island"
replace femalegovnow=1 if state=="Oregon"
replace femalegovnow=1 if state=="Alabama"
replace femalegovnow=1 if state=="Iowa"
replace femalegovnow=1 if state=="Michigan"
replace femalegovnow=1 if state=="New Mexico"
replace femalegovnow=1 if state=="Maine"
replace femalegovnow=1 if state=="South Dakota"
replace femalegovnow=1 if state=="Kansas"

**And create a variable measuring if the respodent lives in a state that had a black gov in the past 30 years (since 1990).**
gen blackgov30=0
replace blackgov30=1 if state=="Virginia"
replace blackgov30=1 if state=="New York"
replace blackgov30=1 if state=="Massachusetts"
**Note that there has never been a black female governor of a US state. So all these former govs. were black men.**
**At the time of my experiments, there were no black governors.**

**Create dummy variable measuring if the subject lives in a state with a GOP governor in 2019**
gen gopgov=1
replace gopgov=0 if state=="California" 
replace gopgov=. if state=="District of Columbia"
replace gopgov=0 if state=="Colorado"
replace gopgov=0 if state=="Connecticut"
replace gopgov=0 if state=="Delaware"
replace gopgov=0 if state=="Hawaii"
replace gopgov=0 if state=="Illinois"
replace gopgov=0 if state=="Kansas"
replace gopgov=0 if state=="Kentucky"
replace gopgov=0 if state=="Louisiana"
replace gopgov=0 if state=="Maine"
replace gopgov=0 if state=="Michigan"
replace gopgov=0 if state=="Minnesota"
replace gopgov=0 if state=="Montana"
replace gopgov=0 if state=="Nevada"
replace gopgov=0 if state=="New Jersey"
replace gopgov=0 if state=="New Mexico"
replace gopgov=0 if state=="New York"
replace gopgov=0 if state=="North Carolina"
replace gopgov=0 if state=="Oregon"
replace gopgov=0 if state=="Pennsylvania"
replace gopgov=0 if state=="Rhode Island"
replace gopgov=0 if state=="Virginia"
replace gopgov=0 if state=="Washington"
replace gopgov=0 if state=="Wisconsin"

**Create variables measuring political knowledge.**
**"Q147: Whose responsibility is it to decide if a law is constitutional or not?"**

gen constitutional2=0
**0 reflects wrong answers or no answer.**
replace constitutional2=1 if constitutional=="The Supreme Court"

**"Q149: Whose responsibility is it to nominate judges to Federal Courts?"**

gen nominatejudges2=0
replace nominatejudges2=1 if nominatejudges=="The President"

**"Q153: Do you know what job or political office is currently held by Nancy Pelosi?"**

gen pelosi2=0
replace pelosi2=1 if pelosi=="Speaker of the House"

**"Q155: Do you know what job or political office is currently held by Steve Mnuchin?"**

gen mnuchin2=0
replace mnuchin2=1 if mnuchin=="Treasury Secretary"

gen polknowledge=mnuchin2+pelosi2+constitutional2+nominatejudges2
**This creates a single political knowledge variable measuring how many of these questions the respondents got right.**

**Now we are going to create a measure of attentiveness.**

gen highquality=0
replace highquality=1 if redgreen=="Red,Green"
**In an initial survey question, subjects were told to choose red and green as their favorite colors,**
**no matter what their favorite colors really are. Here, subjects who answered correctly are coded**
**as high-quality subjects.**

**generate IDs**
gen id=_n
order id

**fix coding of electability scores**
gen ceomw2=.
replace ceomw2=1 if ceomw=="Very unelectable"
replace ceomw2=2 if ceomw=="Somewhat unelectable"
replace ceomw2=3 if ceomw=="Somewhat electable"
replace ceomw2=4 if ceomw=="Very electable"
drop ceomw
rename ceomw2 ceomw
//ceomw refers to the white, male CEO candidate profile//

gen ceomb2=.
replace ceomb2=1 if ceomb=="Very unelectable"
replace ceomb2=2 if ceomb=="Somewhat unelectable"
replace ceomb2=3 if ceomb=="Somewhat electable"
replace ceomb2=4 if ceomb=="Very electable"
drop ceomb
rename ceomb2 ceomb
//ceomb refers to the black, male CEO candidate profile//

gen ceofw2=.
replace ceofw2=1 if ceofw=="Very unelectable"
replace ceofw2=2 if ceofw=="Somewhat unelectable"
replace ceofw2=3 if ceofw=="Somewhat electable"
replace ceofw2=4 if ceofw=="Very electable"
drop ceofw
rename ceofw2 ceofw
//ceofw refers to the female, white CEO candidate profile//

gen ceofb2=.
replace ceofb2=1 if ceofb=="Very unelectable"
replace ceofb2=2 if ceofb=="Somewhat unelectable"
replace ceofb2=3 if ceofb=="Somewhat electable"
replace ceofb2=4 if ceofb=="Very electable"
drop ceofb
rename ceofb2 ceofb
//ceomb refers to the black, female CEO candidate profile//

gen agmw2=.
replace agmw2=1 if agmw=="Very unelectable"
replace agmw2=2 if agmw=="Somewhat unelectable"
replace agmw2=3 if agmw=="Somewhat electable"
replace agmw2=4 if agmw=="Very electable"
drop agmw
rename agmw2 agmw
//agmw refers to the male white attorney general profile//

gen agfw2=.
replace agfw2=1 if agfw=="Very unelectable"
replace agfw2=2 if agfw=="Somewhat unelectable"
replace agfw2=3 if agfw=="Somewhat electable"
replace agfw2=4 if agfw=="Very electable"
drop agfw
rename agfw2 agfw
//agfw refers to the female white attorney general profile//

gen agmb2=.
replace agmb2=1 if agmb=="Very unelectable"
replace agmb2=2 if agmb=="Somewhat unelectable"
replace agmb2=3 if agmb=="Somewhat electable"
replace agmb2=4 if agmb=="Very electable"
drop agmb
rename agmb2 agmb
//agmb refers to the male black attorney general profile//

gen agfb2=.
replace agfb2=1 if agfb=="Very unelectable"
replace agfb2=2 if agfb=="Somewhat unelectable"
replace agfb2=3 if agfb=="Somewhat electable"
replace agfb2=4 if agfb=="Very electable"
drop agfb
rename agfb2 agfb
//agfb refers to the black female attorney general profile//

gen lgmw2=.
replace lgmw2=1 if lgmw=="Very unelectable"
replace lgmw2=2 if lgmw=="Somewhat unelectable"
replace lgmw2=3 if lgmw=="Somewhat electable"
replace lgmw2=4 if lgmw=="Very electable"
drop lgmw
rename lgmw2 lgmw
//lgmw refers to the male white lt. gov. profile//

gen lgfw2=.
replace lgfw2=1 if lgfw=="Very unelectable"
replace lgfw2=2 if lgfw=="Somewhat unelectable"
replace lgfw2=3 if lgfw=="Somewhat electable"
replace lgfw2=4 if lgfw=="Very electable"
drop lgfw
rename lgfw2 lgfw
//lgfw refers to the female white lt. gov. profile//

gen lgmb2=.
replace lgmb2=1 if lgmb=="Very unelectable"
replace lgmb2=2 if lgmb=="Somewhat unelectable"
replace lgmb2=3 if lgmb=="Somewhat electable"
replace lgmb2=4 if lgmb=="Very electable"
drop lgmb
rename lgmb2 lgmb
//lgmb refers to the male black lt. gov. profile//

gen lgfb2=.
replace lgfb2=1 if lgfb=="Very unelectable"
replace lgfb2=2 if lgfb=="Somewhat unelectable"
replace lgfb2=3 if lgfb=="Somewhat electable"
replace lgfb2=4 if lgfb=="Very electable"
drop lgfb
rename lgfb2 lgfb
//lgfb refers to the female black lt. gov. profile//

**Generate indicator of male profile**

**Male2 indicates whether the LG profile was male**
gen male2=0
replace male2=1 if lgmb==1
replace male2=1 if lgmb==2
replace male2=1 if lgmb==3
replace male2=1 if lgmb==4
replace male2=1 if lgmw==1
replace male2=1 if lgmw==2
replace male2=1 if lgmw==4
replace male2=1 if lgmw==3

**Male1 indicates whether the AG profile was male**
gen male1=0
replace male1=1 if agmb==1
replace male1=1 if agmb==2
replace male1=1 if agmb==4
replace male1=1 if agmb==3
replace male1=1 if agmw==1
replace male1=1 if agmw==2
replace male1=1 if agmw==4
replace male1=1 if agmw==3

**Male3 indicates whether the CEO Profile was male**
gen male3=0
replace male3=1 if ceomb==1
replace male3=1 if ceomb==2
replace male3=1 if ceomb==4
replace male3=1 if ceomb==3
replace male3=1 if ceomw==1
replace male3=1 if ceomw==2
replace male3=1 if ceomw==4
replace male3=1 if ceomw==3

**check that this worked**
hist male1
sum male1

hist male2
sum male2

hist male3
sum male3

**Generate Race Variables**
gen white1=0
replace white1=1 if agmw==1
replace white1=1 if agmw==2
replace white1=1 if agmw==4
replace white1=1 if agmw==3
replace white1=1 if agfw==1
replace white1=1 if agfw==2
replace white1=1 if agfw==4
replace white1=1 if agfw==3

gen white2=0
replace white2=1 if lgmw==1
replace white2=1 if lgmw==2
replace white2=1 if lgmw==4
replace white2=1 if lgmw==3
replace white2=1 if lgfw==1
replace white2=1 if lgfw==2
replace white2=1 if lgfw==4
replace white2=1 if lgfw==3

gen white3=0
replace white3=1 if ceomw==1
replace white3=1 if ceomw==2
replace white3=1 if ceomw==4
replace white3=1 if ceomw==3
replace white3=1 if ceofw==1
replace white3=1 if ceofw==2
replace white3=1 if ceofw==4
replace white3=1 if ceofw==3

**check that this worked**
sum white1
hist white1

sum white2
hist white2

hist white3
sum white3

**Create Resume variables**
gen resume1=.
replace resume1=1 if agfw==1
replace resume1=2 if agfw==2
replace resume1=3 if agfw==3
replace resume1=4 if agfw==4

replace resume1=1 if agmw==1
replace resume1=2 if agmw==2
replace resume1=3 if agmw==3
replace resume1=4 if agmw==4

replace resume1=1 if agfb==1
replace resume1=2 if agfb==2
replace resume1=3 if agfb==3
replace resume1=4 if agfb==4

replace resume1=1 if agmb==1
replace resume1=2 if agmb==2
replace resume1=3 if agmb==3
replace resume1=4 if agmb==4

gen resume2=.
replace resume2=1 if lgfw==1
replace resume2=2 if lgfw==2
replace resume2=3 if lgfw==3
replace resume2=4 if lgfw==4

replace resume2=1 if lgfb==1
replace resume2=2 if lgfb==2
replace resume2=3 if lgfb==3
replace resume2=4 if lgfb==4

replace resume2=1 if lgmb==1
replace resume2=2 if lgmb==2
replace resume2=3 if lgmb==3
replace resume2=4 if lgmb==4

replace resume2=1 if lgmw==1
replace resume2=2 if lgmw==2
replace resume2=3 if lgmw==3
replace resume2=4 if lgmw==4

gen resume3=.
replace resume3=1 if ceofw==1
replace resume3=2 if ceofw==2
replace resume3=3 if ceofw==3
replace resume3=4 if ceofw==4

replace resume3=1 if ceofb==1
replace resume3=2 if ceofb==2
replace resume3=3 if ceofb==3
replace resume3=4 if ceofb==4

replace resume3=1 if ceomw==1
replace resume3=2 if ceomw==2
replace resume3=3 if ceomw==3
replace resume3=4 if ceomw==4

replace resume3=1 if ceomb==1
replace resume3=2 if ceomb==2
replace resume3=3 if ceomb==3
replace resume3=4 if ceomb==4

**check to make sure this worked**
sum resume1
sum resume2
sum resume3

hist resume1
hist resume2
hist resume3

**RESHAPE**
reshape long resume male white , i(id) j(profile)
rename resume electability
//Now the unit of analysis is the CANDIDATE PROFILE.//
//EACH SUBJECT RATED 3 CANDIDATE PROFILES//

**Make candidate profile dummies**

gen profile1=0
replace profile1=1 if profile==1
gen profile2=0
replace profile2=1 if profile==2
gen profile3=0
replace profile3=1 if profile==3

gen whitewoman=0
replace whitewoman=1 if white==1 & male==0
gen blackwoman=0
replace blackwoman=1 if white==0 & male==0
gen blackman=0
replace blackman=1 if white==0 & male==1
gen whiteman=0
replace whiteman=1 if white==1 & male==1

**create comparison variables for use in t-tests**

gen blackmancompare=.
replace blackmancompare=1 if blackman==1
replace blackmancompare=0 if whiteman==1
**this variable (blackmancompare) should be used in the by() field of a t-test**
**it will compare the mean for black male profiles vs. the mean for white male profiles**

**Now let's do the same for all the other relevant comparison groups.**
gen blackwomancompare=.
replace blackwomancompare=1 if blackwoman==1
replace blackwomancompare=0 if whiteman==1

gen whitewomancompare=.
replace whitewomancompare=1 if whitewoman==1
replace whitewomancompare=0 if whiteman==1

**Create dummy variables measuring which level of electability was assigned to each profile**
gen veryelect=.
replace veryelect=0 if elect==1
replace veryelect=0 if elect==2
replace veryelect=0 if elect==3
replace veryelect=1 if elect==4

gen someelect=.
replace somee=0 if elect==1
replace somee=0 if elect==2
replace somee=1 if elect==3
replace somee=0 if elect==4

gen someunelect=.
replace someu=0 if elect==1
replace someu=1 if elect==2
replace someu=0 if elect==3
replace someu=0 if elect==4

gen veryunelect=.
replace veryu=1 if elect==1
replace veryu=0 if elect==2
replace veryu=0 if elect==3
replace veryu=0 if elect==4

******************************************************************************************
*******ANALYSIS 1*************************************************************************
******************************************************************************************

//These are the main results reported in Table 1.2//

reg electability whitewoman blackwoman blackman, cluster(id) robust
reg veryelect whitewoman blackwoman blackman, cluster(id) robust

******************************************************************************************
*******ANALYSIS 2*************************************************************************
****************************************************************************************** 

//This section provides the analysis for the Appendix tables and additional description//
//of the findings in the manuscript.//

//APPENDIX TABLE 1.1//
//add fixed effects by profile//
reg electability whitewoman blackwoman blackman profile2 profile3, cluster(id)
estimates store one
reg veryelect whitewoman blackwoman blackman profile2 profile3, cluster(id)
estimates store two
esttab one two using profilefe, se rtf label addnotes("Standard errors clustered by subject") replace


//APPENDIX TABLE 1.2//
//probit results for the "very electable" DV//
probit veryelect whitewoman blackwoman blackman, cluster(id)
estimates store probit
//ordered probit results for "electability" DV//
oprobit electability whitewoman blackwoman blackman, cluster(id)
estimates store ordprobit
esttab ordprobit probit using probits, se rtf label addnotes("Standard errors clustered by subject") dr(cut1 cut2 cut3) replace

//APPENDIX TABLE 1.3//
//Welch's t-tests comparing black and/or female profiles vs. white male profiles //
ttest electability, by(blackmancompare) w
ttest veryelect, by(blackmancompare) w

ttest electability, by(blackwomancompare) w
ttest veryelect, by(blackwomancompare) w

ttest electability, by(whitewomancompare) w
ttest veryelect, by(whitewomancompare) w


**QUALITY CHECK -- are Experiment 1 results driven by low-quality responses?**

//The survey included a screener question intended to gauge if the respondent was//
//paying attention, reading questions thoroughly, and following instructions.//

//Respondents who answered the screener question correctly are coded as "high quality."//

//Appendix Table 1.4//
reg electability blackman whitewoman blackwoman if highquality==1, cluster(id)
estimates store highqual1
reg veryelect blackman whitewoman blackwoman if highquality==1, cluster(id)
estimates store highqual2
esttab highqual1 highqual2 using highqual, se rtf label addnotes("Standard errors clustered by subject") replace

//using only data from subjects who passed the screener question, the results are similar//
//except that the results for the black male candidates are statistically significant in one//
//model.//

**EXTERNAL VALIDITY CHECK -- are the results being driven by people who are**
**not politically engaged?**

//Unfortunately I do not have direct measures of voter registration, intentions to vote//
//or past voting behavior of the subjects.//

//However, there are several measures of political knowledge and engagement in the survey.//

//The analysis below produces APPENDIX TABLES 1.5 to 1.13//

//The survey asked subjects if they are liberal, cons, moderate, or if they//
//"haven't given much thought" to their ideology.//
//Let's repeat the basic models excluding people who said "haven't given it much thought."//

reg electability blackman whitewoman blackwoman if noideology==0, cluster(id)
estimates store noideol1
reg veryelect blackman whitewoman blackwoman if noideology==0, cluster(id) 
estimates store noideol2
esttab noideol1 noideol2 using noideol, se rtf label addnotes("Standard errors clustered by subject") replace

//There were also 2 questions about gov knowledge -- do subjects know who determines if laws//
//are constitutional, and do they know who nominates federal judges?//

//Now let's repeat the regs only with those who answered both questions right.//

reg electability blackman whitewoman blackwoman if nominatejudges2==1 & constitutional2==1, cluster(id)
estimates store govknow1
reg veryelect blackman whitewoman blackwoman if nominatejudges2==1 & constitutional2==1, cluster(id) 
estimates store govknow2
esttab govknow1 govknow2 using govknow, se rtf label addnotes("Standard errors clustered by subject") replace

//Could some people have guessed the right answers randomly? Yes. So let's repeat the main models including only//
//subjects who passed the attention check question AND answered the two constitutional knowledge questions correctly.//

reg electability blackman whitewoman blackwoman if nominatejudges2==1 & constitutional2==1 & highqual==1, cluster(id)
estimates store govknowhighqual1
reg veryelect blackman whitewoman blackwoman if nominatejudges2==1 & constitutional2==1 & highqual==1, cluster(id) 
estimates store govknowhighqual2
esttab govknowhighqual1 govknowhighqual2 using govknowhighqual, se rtf label addnotes("Standard errors clustered by subject") replace

//There were also questions about ID'ing Nancy Pelosi and Steve Mnuchin.//
//I have some concerns about these (do they introduce a filter for partisanship?) but let's go ahead and use them.//

reg electability blackman whitewoman blackwoman if pelosi2==1 & mnuchin2==1, cluster(id)
estimates store pelosimnuchin1
reg veryelect blackman whitewoman blackwoman if pelosi2==1 & mnuchin2==1, cluster(id)
estimates store pelosimnuchin2
esttab pelosimnuchin1 pelosimnuchin2 using pelosimnuchin, se rtf label addnotes("Standard errors clustered by subject") replace
//I think the results change here because men are much more likely//
//to correctly ID Mnuchin.//

//Now we'll include only those subjects who correctly id'ed Pelosi and Mnuchin and passed the attention check//
//question.//

reg electability blackman whitewoman blackwoman if pelosi2==1 & mnuchin2==1 & highqual==1, cluster(id)
estimates store pelosimnuchinqual1
reg veryelect blackman whitewoman blackwoman if pelosi2==1 & mnuchin2==1 & highqual==1, cluster(id)
estimates store pelosimnuchinqual2
esttab pelosimnuchinqual1 pelosimnuchinqual2 using pelosimnuchinqual, se rtf label addnotes("Standard errors clustered by subject") replace


//I also combined the gov and political knowledge questions into one variable called "polknowledge."//
//It's codes the number of correct answers to the Mnuchin, Pelosi, and constitutional questions.//

//Let's see what happens if we look at the lowest-knowledge respondents only://
reg electability blackman whitewoman blackwoman if polknow==0, cluster(id)
estimates store lowknow1
reg veryelect blackman whitewoman blackwoman if polknow==0, cluster(id)
estimates store lowknow2
esttab lowknow1 lowknow2 using know0, se rtf label addnotes("Standard errors clustered by subject") replace

//Let's see what happens if we look only at subjects who said they "haven't given much thought" to their ideology//
reg electability blackman whitewoman blackwoman if noideol==1, cluster(id)
estimates store noideol1
reg veryelect blackman whitewoman blackwoman if noideol==1, cluster(id)
estimates store noideol2
esttab noideol1 noideol2 using noideol1, se rtf label addnotes("Standard errors clustered by subject") replace

//Let's see what happens if we look at the people who failed the attention check question only.//
reg electability blackman whitewoman blackwoman if highqual==0, cluster(id)
estimates store lowqual1
reg veryelect blackman whitewoman blackwoman if highqual==0, cluster(id)
estimates store lowqual2
esttab lowqual1 lowqual2 using lowqual, se rtf label addnotes("Standard errors clustered by subject") replace
//These subjects are probably introducing "noise" into the overall results. They are certainly not driving my findings.//

//Now let's look at the more knowledgeable subjects only.//
reg electability blackman whitewoman blackwoman if polknow>0, cluster(id)
reg veryelect blackman whitewoman blackwoman if polknow>0, cluster(id)

reg electability blackman whitewoman blackwoman if polknow>1, cluster(id)
reg veryelect blackman whitewoman blackwoman if polknow>1, cluster(id)

reg electability blackman whitewoman blackwoman if polknow>2, cluster(id)
reg veryelect blackman whitewoman blackwoman if polknow>2, cluster(id)

reg electability blackman whitewoman blackwoman if polknow>3, cluster(id)
reg veryelect blackman whitewoman blackwoman if polknow>3, cluster(id)

//Now let's exclude people with no ideology, those who did not pass the attention check//
//and those with very low political knowledge.//

//Essentially, we are left with reasonably knowledgeable, political, and attentive respondents only://
reg electability blackman whitewoman blackwoman if polknow>0 & noideol==0 & highquality==1, cluster(id)
estimates store higherqual1
reg veryelect blackman whitewoman blackwoman if polknow>0 & noideol==0 & highquality==1, cluster(id)
estimates store higherqual2
esttab higherqual1 higherqual2 using higherqual, se rtf label addnotes("Standard errors clustered by subject") replace

//Now let's have a look at the most knowledgeble, attentive, and political respondents only://
reg electability blackman whitewoman blackwoman if polknow>2 & noideol==0 & highquality==1, cluster(id)
estimates store veryhighestqual1
reg veryelect blackman whitewoman blackwoman if polknow>2 & noideol==0 & highquality==1, cluster(id)
estimates store veryhighestqual2
esttab veryhighestqual1 veryhighestqual2 using highestqual2, se rtf label addnotes("Standard errors clustered by subject") replace
//Wow.//

//SUB-GROUP ANALYSIS//

//The code below produces the sub-group analysis cited in manuscript and related Appendix tables.//

//APPENDIX TABLE 1.15//
reg electability blackman whitewoman blackwoman if education<3, cluster(id)
estimates store educ1
reg electability blackman whitewoman blackwoman if education<5 & education>2, cluster(id)
estimates store educ2
reg electability blackman whitewoman blackwoman if education>4, cluster(id)
estimates store educ3
esttab educ1 educ2 educ3 using educelect, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.14//
reg veryelect blackman whitewoman blackwoman if education<3, cluster(id)
estimates store educ4
reg veryelect blackman whitewoman blackwoman if education<5 & education>2, cluster(id)
estimates store educ5
reg veryelect blackman whitewoman blackwoman if education>4, cluster(id)
estimates store educ6
esttab educ4 educ5 educ6 using educvery, se rtf label addnotes("Standard errors clustered by subject") replace

//Now let's look at generational differences.//

//APPENDIX TABLE 1.17//
reg electability blackman whitewoman blackwoman if age<26, cluster(id)
estimates store genz1
reg electability blackman whitewoman blackwoman if age>25 & age<40, cluster(id)
estimates store mil1
reg electability blackman whitewoman blackwoman if age>39 & age<=54, cluster(id)
estimates store genx1
reg electability blackman whitewoman blackwoman if age>=55 & age<71, cluster(id)
estimates store boom1
reg electability blackman whitewoman blackwoman if age>70, cluster(id)
estimates store silent1
esttab genz1 mil1 genx1 boom1 silent1 using genelect, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.16//
reg veryelect blackman whitewoman blackwoman if age<26, cluster(id)
estimates store genz2
reg veryelect blackman whitewoman blackwoman if age>25 & age<40, cluster(id)
estimates store mil2
reg veryelect blackman whitewoman blackwoman if age>39 & age<=54, cluster(id)
estimates store genx2
reg veryelect blackman whitewoman blackwoman if age>=55 & age<71, cluster(id)
estimates store boom2
reg veryelect blackman whitewoman blackwoman if age>70, cluster(id)
estimates store silent2
esttab genz2 mil2 genx2 boom2 silent2 using genveryelect, se rtf label addnotes("Standard errors clustered by subject") replace

**IS INFERRED PARTISANSHIP DRIVING THE RESULTS OF STUDY I?**

//Now look at results from subjects in states with GOP or Democratic governors.//
//This helps us deal with inferred partisanship.//
//If the subjects who see black and/or female candidates as unelectable are mostly in GOP-governed//
//states, then they might think those candidates are unelectable because they are inferring//
//that they're Democrats -- not because of their race/gender.//

//Appendix Table 1.18//
reg electability blackman whitewoman blackwoman if gopgov==0, cluster(id)
estimates store demgov1
reg veryelect blackman whitewoman blackwoman if gopgov==0, cluster(id)
estimates store demgov2
reg electability blackman whitewoman blackwoman if gopgov==1, cluster(id)
estimates store gopgov1
reg veryelect blackman whitewoman blackwoman if gopgov==1, cluster(id)
estimates store gopgov2
esttab demgov1 demgov2 gopgov1 gopgov2 using gov, se rtf label addnotes("Standard errors clustered by subject") replace

**HOW DO ESTIMATES OF OTHERS' UNWILLINGNESS TO VOTE FOR A FEMALE/BLACK PRESIDENT VARY BY SUBJECT DEMOGRAPHICS?**

//This section of code summarizes and analyzes each subject's estimates of the percentage of other//
//Americans who would not vote for a woman for president, and the percentage of other Americans who//
//would not vote for a black person for president.//

//Summary stats for "not vote for a woman" by respondent characteristics//
//For APPENDIX TABLE 1.33//
sum notvotewoman if age<35
sum notvotewoman if 34<age & age<55
sum notvotewoman if age>54

sum notvotewoman if femaleresp==1
sum notvotewoman if maleresp==1

sum notvotewoman if education<3
//that's HS dropout or HS grad only//
sum notvotewoman if education>2 & education<5
//that's some college but not a 4 yr degree//
sum notvotewoman if education==5
//that's a 4 yr degree//
sum notvotewoman if education==6
//that's a postgrad degree//

sum notvotewoman if liberal==0 & conservative==0 & noideol==0
sum notvotewoman if liberal==1
sum notvotewoman if conserva==1

sum notvotewoman if dem==1
sum notvotewoman if rep==1
sum notvotewoman if indep==1

sum notvotewoman if whiteresp==1
sum notvotewoman if blackresp==1
sum notvotewoman if hispanicresp==1
sum notvotewoman if apiresp==1

//Summary stats for "not vote for a black person" by respondent characteristics//
sum notvoteblack if age<35
sum notvoteblack if 34<age & age<55
sum notvoteblack if age>54

sum notvoteblack if femaleresp==1
sum notvoteblack if maleresp==1

sum notvoteblack if education<3
**that's HS dropout or HS grad only**
sum notvoteblack if education>2 & education<5
**that's some college but not a 4 yr degree**
sum notvoteblack if education==5
**that's a 4 yr degree*
sum notvoteblack if education==6
**that's a postgrad degree**

sum notvoteblack if conserva==1
sum notvoteblack if liberal==1
sum notvoteblack if liberal==0 & conservative==0

sum notvoteblack if dem==1
sum notvoteblack if rep==1
sum notvoteblack if indep==1

sum notvoteblack if whiteresp==1
sum notvoteblack if blackresp==1
sum notvoteblack if hispanicresp==1
sum notvoteblack if apiresp==1

**EVALUATING THE MECHANISM**
**DO SUBJECTS' RESPONSES TO STUDY 1 VARY ACCORDING TO THEIR ESTIMATES OF OTHERS' BIASES?**

//This section of code evaluations whether subjects who under- and over-estimated others'//
//biases responded differently to the experiment. The basic answer is: yes.//

//Because there are multiple ways to code who is an "over-estimator" and who is an "under-estimator"//
//I use a series of different cut points in the analysis below.//

//These tables look at differences between over- and under-estimators of others' SEXISM//
//The cut-points are 10%, 15%, 20%, 25%, and 30%//

//APPENDIX TABLE 1.19//
reg elect blackman whitewoman blackwoman if notvotewoman<11, cluster(id)
estimates store cut1
reg veryelect blackman whitewoman blackwoman if notvotewoman<11, cluster(id)  
estimates store cut2
reg elect blackman whitewoman blackwoman if notvotewoman>=11, cluster(id)
estimates store cut3
reg veryelect blackman whitewoman blackwoman if notvotewoman>=11, cluster(id)
estimates store cut4
esttab cut1 cut2 cut3 cut4 using nvw10, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.20//
reg elect blackman whitewoman blackwoman if notvotewoman<16, cluster(id)
estimates store cut5
reg veryelect blackman whitewoman blackwoman if notvotewoman<16, cluster(id)  
estimates store cut6
reg elect blackman whitewoman blackwoman if notvotewoman>=16, cluster(id)
estimates store cut7
reg veryelect blackman whitewoman blackwoman if notvotewoman>=16, cluster(id)
estimates store cut8
esttab cut5 cut6 cut7 cut8 using nvw15, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.21//
reg elect blackman whitewoman blackwoman if notvotewoman<21, cluster(id)
estimates store cut9
reg veryelect blackman whitewoman blackwoman if notvotewoman<21, cluster(id)  
estimates store cut10
reg elect blackman whitewoman blackwoman if notvotewoman>=21, cluster(id)
estimates store cut11
reg veryelect blackman whitewoman blackwoman if notvotewoman>=21, cluster(id)
estimates store cut12
esttab cut9 cut10 cut11 cut12 using nvw20, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.22//
reg elect blackman whitewoman blackwoman if notvotewoman<26, cluster(id)
estimates store cut13
reg veryelect blackman whitewoman blackwoman if notvotewoman<26, cluster(id)  
estimates store cut14
reg elect blackman whitewoman blackwoman if notvotewoman>=26, cluster(id)
estimates store cut15
reg veryelect blackman whitewoman blackwoman if notvotewoman>=26, cluster(id)
estimates store cut16
esttab cut13 cut14 cut15 cut16 using nvw25, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.23//
reg elect blackman whitewoman blackwoman if notvotewoman<31, cluster(id)
estimates store cut17
reg veryelect blackman whitewoman blackwoman if notvotewoman<31, cluster(id)  
estimates store cut18
reg elect blackman whitewoman blackwoman if notvotewoman>=31, cluster(id)
estimates store cut19
reg veryelect blackman whitewoman blackwoman if notvotewoman>=31, cluster(id)
estimates store cut20
esttab cut17 cut18 cut19 cut20 using nvw30, se rtf label addnotes("Standard errors clustered by subject") replace

//Now we'll repeat this entire exercise for the over- and under-estimators of others' racism.//

//Actually, I'll start the cut-points at 5%, because there are more subjects with very low//
//estimates of others' racism.//

//APPENDIX TABLE 1.24//
reg elect blackman whitewoman blackwoman if notvoteblack<6, cluster(id)
estimates store cut24
reg veryelect blackman whitewoman blackwoman if notvoteblack<6, cluster(id)  
estimates store cut25
reg elect blackman whitewoman blackwoman if notvoteblack>=6, cluster(id)
estimates store cut26
reg veryelect blackman whitewoman blackwoman if notvoteblack>=6, cluster(id)
estimates store cut27
esttab cut24 cut25 cut26 cut27 using nvb5, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.25//
reg elect blackman whitewoman blackwoman if notvoteblack<11, cluster(id)
estimates store cut20
reg veryelect blackman whitewoman blackwoman if notvoteblack<11, cluster(id)  
estimates store cut21
reg elect blackman whitewoman blackwoman if notvoteblack>=11, cluster(id)
estimates store cut22
reg veryelect blackman whitewoman blackwoman if notvoteblack>=11, cluster(id)
estimates store cut23
esttab cut20 cut21 cut22 cut23 using nvb10, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.26//
reg elect blackman whitewoman blackwoman if notvoteblack<16, cluster(id)
estimates store cut30
reg veryelect blackman whitewoman blackwoman if notvoteblack<16, cluster(id)  
estimates store cut31
reg elect blackman whitewoman blackwoman if notvoteblack>=16, cluster(id)
estimates store cut32
reg veryelect blackman whitewoman blackwoman if notvoteblack>=16, cluster(id)
estimates store cut33
esttab cut30 cut31 cut32 cut33 using nvb15, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.27//
reg elect blackman whitewoman blackwoman if notvoteblack<21, cluster(id)
estimates store cut40
reg veryelect blackman whitewoman blackwoman if notvoteblack<21, cluster(id)  
estimates store cut41
reg elect blackman whitewoman blackwoman if notvoteblack>=21, cluster(id)
estimates store cut42
reg veryelect blackman whitewoman blackwoman if notvoteblack>=21, cluster(id)
estimates store cut43
esttab cut40 cut41 cut42 cut43 using nvb20, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.28//
reg elect blackman whitewoman blackwoman if notvoteblack<26, cluster(id)
estimates store cut50
reg veryelect blackman whitewoman blackwoman if notvoteblack<26, cluster(id)  
estimates store cut51
reg elect blackman whitewoman blackwoman if notvoteblack>=26, cluster(id)
estimates store cut52
reg veryelect blackman whitewoman blackwoman if notvoteblack>=26, cluster(id)
estimates store cut53
esttab cut50 cut51 cut52 cut53 using nvb25, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.29//
reg elect blackman whitewoman blackwoman if notvoteblack<31, cluster(id)
estimates store cut60
reg veryelect blackman whitewoman blackwoman if notvoteblack<31, cluster(id)  
estimates store cut61
reg elect blackman whitewoman blackwoman if notvoteblack>=31, cluster(id)
estimates store cut62
reg veryelect blackman whitewoman blackwoman if notvoteblack>=31, cluster(id)
estimates store cut63
esttab cut60 cut61 cut62 cut63 using nvb30, se rtf label addnotes("Standard errors clustered by subject") replace
 
**DO SUBJECTS FROM STATES THAT HAVE HAD DIVERSE GOVERNORS SEE**
**FEMALE AND BLACK CANDIDATES AS MORE ELECTABLE?**

//In short, not really.//

//Let's look at subjects from states that have had (mostly white) female governors or black (male) governors//
//Do people from those states think differently about who is "electable"?//

//(Note that the US has never had a black female governor)//

//APPENDIX TABLE 1.31//
reg elect blackman whitewoman blackwoman if femalegovnow==1, cluster(id)
estimates store fgovnow1
reg veryelect blackman whitewoman blackwoman if femalegovnow==1, cluster(id)
estimates store fgovnow2
esttab fgovnow1 fgovnow2 using fgovnow, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.30//
reg elect blackman whitewoman blackwoman if femalegov30==1, cluster(id)
estimates store fgov301
reg veryelect blackman whitewoman blackwoman if femalegov30==1, cluster(id)
estimates store fgov302
esttab fgov301 fgov302 using fgov30, se rtf label addnotes("Standard errors clustered by subject") replace

//APPENDIX TABLE 1.32//
reg elect blackman whitewoman blackwoman if blackgov30==1, cluster(id)
estimates store bgov301
reg veryelect blackman whitewoman blackwoman if blackgov30==1, cluster(id)
estimates store bgov302
esttab bgov301 bgov302 using bgov30, se rtf label addnotes("Standard errors clustered by subject") replace

//Whew! That's the end of this do-file.//

//To replicate the Study 2 results, please use the do-file Study2_Analysis.do//

clear 
